package com.wxg.controller;

import com.wxg.config.rocketmq.IRocketMqSelector;
import com.wxg.domain.MqConstant;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author void
 * @date 2020/6/1 15:00
 * @desc
 */
@RestController
@RequestMapping("/mq")
public class MqController {
    
    @GetMapping("/queue")
    public void testQueue(Integer queue) throws Exception {
        DefaultMQProducer producer = new DefaultMQProducer("GID_VOID_2");
        producer.setNamesrvAddr("172.16.1.100:9876");
        producer.start();
        Message msg = new Message("TOPIC_VOID_2", "TagB", "hello rocketMq 测试渠道".getBytes());
        SendResult sendResult = producer.send(msg, new IRocketMqSelector(), queue);
        System.out.println(sendResult);
        producer.shutdown();
    }
}
